using DG.Tweening;
using Spine;
using Spine.Unity;
using Spine.Unity.Modules;
using System.Collections;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
	public tk2dTextMesh[] texhMeshNumberCountdown;

	public tk2dClippedSprite bloodPlayer;

	public GamePlayController target;

	private SkeletonAnimation skeletonAnimationHead;

	public GameObject Boxskill1;

	public GameObject Boxskill2;

	public GameObject BoxSlide;

	public GameObject BoxBigHealth;

	private GameObject _target;

	private GameObject _target1;

	public GameObject Effskill2Cloud;

	public GameObject Effskill1Cloud;

	public GameObject Bullet1Cross;

	public GameObject Bullet2Cross;

	public GameObject Effskill22Cross;

	public GameObject Effskill1Cross;

	public GameObject Effskill2Cross;

	public GameObject Effskill2Katana;

	public GameObject Effskill2Claw;

	public GameObject Effskill2Pike;

	public GameObject Effatk5Zed;

	public GameObject Effskill1Zed;

	public GameObject BoxHealth;

	public GameObject EffOfBuffHealth;

	public GameObject EffOfLevelUp;

	public GameObject[] HandTutorial;

	public GameObject tangAttack;

	public GameObject tangDefense;

	public GameObject bieutuongAttack;

	public GameObject bieutuongThu;

	public GameObject PlayerPhanThan;

	public GameObject Tinker;

	public GameObject EffStart;

	private GameObject EffDragCloud;

	private float speed = 3.2f;

	public float HealthMaxPlayer = 500f;

	private float distance;

	private float distance1;

	private float healthLocal;

	private float healthOfWeapon;

	private float distanceFollowStick;

	private float HealthTinkerIncrease;

	private float HealthPlayerNotTinker;

	private float HealthTinkerBellperSecond;

	private float phantramtinker;

	private float[] distanceAtkAll = new float[10]
	{
		1.3f,
		2.2f,
		2f,
		2.2f,
		2.2f,
		2.5f,
		5f,
		2.7f,
		2f,
		2f
	};

	private float[] hpWeaponAll = new float[10]
	{
		0f,
		3000f,
		8000f,
		14000f,
		25000f,
		40000f,
		60000f,
		90000f,
		140000f,
		200000f
	};

	private bool attack;

	private bool skill1;

	private bool skill2;

	private bool isComplete = true;

	public bool PlayerisDeath;

	private bool chuyen;

	private bool checkSound;

	private bool istangdame;

	private bool istangthu;

	public bool isBanra;

	private bool ishurt;

	private bool isright = true;

	private bool isSlide;

	private bool isGhost;

	private bool isTrail;

	private bool isAtk4;

	private Transform AttackZed;

	private Transform SkillZed2;

	private Transform attackOfCross;

	private int idWp;

	private int go = -1;

	private int a;

	private int countskill1countdown = 20;

	private int countskill2countdown = 40;

	private int countslidecountdown = 5;

	private int hesotangthu = 10;

	private int atkSkAxe;

	private int increaseCoin;

	private int countskillCross;

	public int damagePlayer;

	private int totaldamageWeapon;

	public int damageSkill;

	private int[] tangdamePlayer = new int[6]
	{
		0,
		10,
		25,
		45,
		70,
		100
	};

	private int[][] damageVukhi = new int[10][]
	{
		new int[6]
		{
			25,
			50,
			75,
			110,
			150,
			200
		},
		new int[6]
		{
			150,
			300,
			450,
			600,
			850,
			1050
		},
		new int[6]
		{
			650,
			800,
			1000,
			1400,
			1700,
			2100
		},
		new int[6]
		{
			1500,
			1900,
			2500,
			3300,
			4300,
			5500
		},
		new int[6]
		{
			4000,
			5000,
			6500,
			8000,
			9500,
			11500
		},
		new int[6]
		{
			7500,
			9000,
			12500,
			14000,
			17000,
			20000
		},
		new int[6]
		{
			5000,
			6000,
			7000,
			8000,
			9000,
			10000
		},
		new int[6]
		{
			24000,
			32000,
			42000,
			52000,
			62000,
			75000
		},
		new int[6]
		{
			33000,
			45000,
			58000,
			72000,
			85000,
			100000
		},
		new int[6]
		{
			45000,
			60000,
			75000,
			95000,
			115000,
			140000
		}
	};

	private int[] damageNormal = new int[90]
	{
		25,
		50,
		75,
		100,
		125,
		150,
		175,
		200,
		225,
		250,
		275,
		300,
		325,
		350,
		375,
		400,
		425,
		450,
		475,
		600,
		630,
		680,
		710,
		770,
		850,
		930,
		960,
		990,
		1020,
		1050,
		1100,
		1150,
		1200,
		1300,
		1400,
		1500,
		1600,
		1700,
		1800,
		1900,
		2000,
		2100,
		2200,
		2300,
		2400,
		2500,
		2600,
		2700,
		2800,
		2900,
		3000,
		3400,
		3500,
		3600,
		3700,
		3800,
		4000,
		4200,
		4400,
		4700,
		5000,
		5500,
		6000,
		6500,
		7000,
		7500,
		8000,
		8500,
		9000,
		9500,
		10500,
		11000,
		11300,
		11500,
		11800,
		12200,
		12600,
		13100,
		13600,
		14100,
		14600,
		15200,
		15800,
		16200,
		16800,
		16400,
		17000,
		17800,
		18600,
		20000
	};

	private readonly string[] AnimationName = new string[12]
	{
		"idle",
		"hit",
		"walk",
		"attack1",
		"attack2",
		"attack3",
		"attack4",
		"skill1",
		"skill2",
		"attack5",
		"die",
		"slide"
	};

	private void Start()
	{
		idWp = GameManager.indexVukhi;
		UnityEngine.Object.Destroy(EffStart, 2f);
		if (GameManager.Tinker > 0)
		{
			Tinker.SetActive(value: true);
			TinkerBuff();
			phantramtinker = 15f;
		}
		GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("Player/" + idWp)) as GameObject;
		gameObject.transform.parent = base.transform;
		gameObject.transform.localPosition = Vector3.zero;
		if (idWp == 6)
		{
			attackOfCross = gameObject.GetComponent<Special>().pointAtk;
		}
		else if (idWp == 9)
		{
			AttackZed = gameObject.GetComponent<Special>().pointAtk;
		}
		else if (idWp == 5)
		{
			EffDragCloud = gameObject.GetComponent<Special>().EffSpecial;
		}
		skeletonAnimationHead = GetComponentInChildren<SkeletonAnimation>();
		skeletonAnimationHead.state.Complete += AnimationComplete;
		skeletonAnimationHead.state.Event += ActiveSkill;
		distanceFollowStick = distanceAtkAll[idWp];
		healthOfWeapon = hpWeaponAll[idWp];
		HealthPlayerNotTinker = (float)(500 * GameManager.levelPlayer) + healthOfWeapon;
		HealthTinkerIncrease = HealthPlayerNotTinker * phantramtinker / 100f;
		HealthMaxPlayer = HealthPlayerNotTinker + HealthTinkerIncrease;
		HealthTinkerBellperSecond = HealthMaxPlayer * 1.5f / 100f;
		healthLocal = HealthMaxPlayer;
		totaldamageWeapon = damageVukhi[idWp][GameManager.levelUpgrade[idWp]] + damageNormal[GameManager.levelPlayer - 1];
		damagePlayer = totaldamageWeapon + totaldamageWeapon * tangdamePlayer[GameManager.levelUpgrade[0]] / 100;
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 2)
		{
			HandTutorial[2].SetActive(value: true);
		}
		if (GameManager.stage <= 20)
		{
			increaseCoin = 20;
		}
		else if (GameManager.stage > 20 && GameManager.stage <= 30)
		{
			increaseCoin = 30;
		}
		else if (GameManager.stage > 30 && GameManager.stage <= 40)
		{
			increaseCoin = 50;
		}
		else if (GameManager.stage > 40 && GameManager.stage <= 50)
		{
			increaseCoin = 60;
		}
		else
		{
			increaseCoin = 70;
		}
	}

	private void Update()
	{
		if (_target == null)
		{
			FindEnemy();
		}
		else
		{
			distance = Vector3.Distance(base.transform.position, _target.transform.position);
		}
		if (_target1 == null)
		{
			FindBoom();
		}
		else
		{
			distance1 = Vector3.Distance(base.transform.position, _target1.transform.position);
		}
		if (PlayerisDeath)
		{
			return;
		}
		if (go == 1)
		{
			ishurt = false;
			Vector3 position = base.transform.position;
			if (position.x < 18.5f && !skill1 && !skill2 && !isSlide && !isBanra)
			{
				base.transform.localScale = new Vector3(1f, 1f, 1f);
				if (!attack)
				{
					GetComponent<Rigidbody2D>().velocity = Vector2.right * speed;
					isright = true;
					SetAnim(AnimationName[2], loop: true);
				}
			}
		}
		if (go == 0)
		{
			ishurt = false;
			Vector3 position2 = base.transform.position;
			if (position2.x > -5f && !skill1 && !skill2 && !isSlide && !isBanra)
			{
				base.transform.localScale = new Vector3(-1f, 1f, 1f);
				if (!attack)
				{
					GetComponent<Rigidbody2D>().velocity = -Vector2.right * speed;
					isright = false;
					SetAnim(AnimationName[2], loop: true);
				}
			}
		}
		else if (go == -1 && !attack && !skill1 && !skill2 && isComplete && !ishurt && !isSlide && !isBanra)
		{
			SetAnim(AnimationName[0], loop: true);
			GetComponent<Rigidbody2D>().velocity = Vector2.zero;
			chuyen = false;
			if (GameManager.indexVukhi == 5)
			{
				EffDragCloud.SetActive(value: false);
			}
		}
		if (attack && !skill1 && !skill2 && !isSlide && !isBanra)
		{
			if (a == 0 && !chuyen)
			{
				SetAnim(AnimationName[3], loop: false);
				isComplete = true;
			}
			else if (a == 1 && chuyen && !isComplete)
			{
				SetAnim(AnimationName[4], loop: false);
				isComplete = true;
			}
			else if (a == 2 && chuyen && !isComplete)
			{
				SetAnim(AnimationName[5], loop: false);
				isComplete = true;
			}
			else if (a == 3 && chuyen && !isComplete)
			{
				SetAnim(AnimationName[6], loop: false);
				isComplete = true;
			}
			else if (a == 4 && chuyen && !isComplete)
			{
				if (idWp == 8)
				{
					isAtk4 = true;
				}
				SetAnim(AnimationName[9], loop: false);
				isComplete = true;
			}
			else if (!isComplete)
			{
				SetAnim(AnimationName[3], loop: false);
			}
		}
		if (isSlide && !skill1 && !skill2 && isComplete && !isBanra)
		{
			ishurt = false;
			SetAnim(AnimationName[11], loop: false);
			isComplete = false;
			if (isright)
			{
				GetComponent<Rigidbody2D>().velocity = Vector2.right * 7.5f;
			}
			else
			{
				GetComponent<Rigidbody2D>().velocity = -Vector2.right * 7.5f;
			}
		}
		if (skill1 && !skill2 && !isSlide && isComplete && !isBanra)
		{
			ishurt = false;
			SetAnim(AnimationName[7], loop: false);
			isComplete = false;
			GetComponent<Rigidbody2D>().velocity = Vector2.zero;
		}
		if (skill2 && !skill1 && !isSlide && isComplete && !isBanra)
		{
			ishurt = false;
			SetAnim(AnimationName[8], loop: false);
			isComplete = false;
			GetComponent<Rigidbody2D>().velocity = Vector2.zero;
		}
		if (isGhost)
		{
			GetComponentInChildren<SkeletonGhost>().ghostingEnabled = true;
		}
		else
		{
			GetComponentInChildren<SkeletonGhost>().ghostingEnabled = false;
		}
	}

	private void SetAnim(string nameAnim, bool loop)
	{
		if (skeletonAnimationHead.AnimationName != nameAnim)
		{
			skeletonAnimationHead.state.SetAnimation(0, nameAnim, loop);
		}
	}

	private void OnclickSkill1()
	{
		if (!skill2 && !isSlide && !attack && !isGhost)
		{
			skill1 = true;
			StartCoroutine(countDownSkill1());
			if (idWp == 9)
			{
				PlayerPhanThan.GetComponent<PlayerZedController>().OnclickSkill1();
			}
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 3)
		{
			HandTutorial[3].SetActive(value: false);
		}
	}

	private void OnclickSkill2()
	{
		if (!skill1 && !isSlide && !attack && !isGhost)
		{
			skill2 = true;
			StartCoroutine(countDownSkill2());
			if (idWp == 9)
			{
				PlayerPhanThan.GetComponent<PlayerZedController>().OnclickSkill2();
			}
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 4)
		{
			HandTutorial[4].SetActive(value: false);
		}
	}

	public void OnclickAttack()
	{
		if (!isSlide && !isAtk4)
		{
			attack = true;
			GetComponent<Rigidbody2D>().velocity = Vector2.zero;
			isComplete = false;
			if (idWp == 9)
			{
				PlayerPhanThan.GetComponent<PlayerZedController>().OnclickAttack();
			}
			else if (idWp == 5)
			{
				EffDragCloud.SetActive(value: false);
			}
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 2)
		{
			GameManager.number_tutorial++;
			HandTutorial[2].SetActive(value: false);
			HandTutorial[3].SetActive(value: true);
			GameObject.Find("Skill1").GetComponent<Collider>().enabled = true;
			GameObject.Find("Attack").GetComponent<Collider>().enabled = false;
		}
	}

	private void OnclickSlide()
	{
		if (!isSlide && !skill1 && !skill2)
		{
			isSlide = true;
			isGhost = true;
			StartCoroutine(countDownSlide());
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 5)
		{
			GameManager.number_tutorial++;
			HandTutorial[5].SetActive(value: false);
			target.SinhStage1();
			GameObject.Find("Skill2").GetComponent<Collider>().enabled = true;
			GameObject.Find("Skill1").GetComponent<Collider>().enabled = true;
			GameObject.Find("Attack").GetComponent<Collider>().enabled = true;
		}
	}

	public void Playergoleft()
	{
		go = 0;
		if (idWp == 5)
		{
			EffDragCloud.SetActive(value: true);
		}
		else if (idWp == 9)
		{
			PlayerPhanThan.GetComponent<PlayerZedController>().Playergoleft();
			PlayerPhanThan.GetComponent<PlayerZedController>().isright = false;
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 0)
		{
			HandTutorial[0].SetActive(value: false);
			HandTutorial[1].SetActive(value: true);
			Invoke("abc", 0.5f);
		}
	}

	public void Playergoright()
	{
		go = 1;
		if (idWp == 5)
		{
			EffDragCloud.SetActive(value: true);
		}
		else if (idWp == 9)
		{
			PlayerPhanThan.GetComponent<PlayerZedController>().Playergoright();
			PlayerPhanThan.GetComponent<PlayerZedController>().isright = true;
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 1)
		{
			HandTutorial[1].SetActive(value: false);
			HandTutorial[2].SetActive(value: true);
			Invoke("abc", 0.5f);
			GameObject.Find("Attack").GetComponent<Collider>().enabled = true;
		}
	}

	public void MoveChar(Vector2 _move)
	{
		if (_move.x < 0f && !skill1 && !skill2 && !isSlide)
		{
			isright = false;
			Playergoleft();
		}
		else if (_move.x >= 0f && !skill1 && !skill2 && !isSlide)
		{
			isright = true;
			Playergoright();
		}
	}

	public void PlayerIdle()
	{
		go = -1;
		if (GameManager.indexVukhi == 9)
		{
			PlayerPhanThan.GetComponent<PlayerZedController>().PlayerIdle();
		}
	}

	private void AnimationComplete(TrackEntry entry)
	{
		if (entry.animation.name != AnimationName[0] && entry.animation.name != AnimationName[2])
		{
			if (entry.animation.name == AnimationName[10] && GameManager.numberRate >= 3)
			{
				AdsVideoController.ShowAdFull();
			}
			attack = false;
			skill1 = false;
			skill2 = false;
			isSlide = false;
			isComplete = true;
			ishurt = false;
			chuyen = false;
			isGhost = false;
			isAtk4 = false;
			a = 0;
			atkSkAxe = 0;
			checkSound = false;
		}
	}

	private void ActiveSkill(TrackEntry entry, Spine.Event e)
	{
		if (e.ToString() == "attack")
		{
			switch (idWp)
			{
			case 0:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack5")
				{
					attack4none();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1none();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2none();
				}
				break;
			case 1:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack4")
				{
					attack4gay();
				}
				if (entry.animation.name == "attack5")
				{
					attack4none();
				}
				else if (entry.animation.name == "skill2")
				{
					skill1gay();
				}
				else if (entry.animation.name == "skill1")
				{
					skill2gay();
				}
				break;
			case 2:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				if (entry.animation.name == "attack5")
				{
					attack4none();
				}
				else if (entry.animation.name == "skill1")
				{
					skill2Claw();
				}
				else if (entry.animation.name == "skill2")
				{
					skill1Claw();
				}
				break;
			case 3:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack34Dao();
				}
				else if (entry.animation.name == "attack5")
				{
					attack5Dao();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Dao();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Dao();
				}
				break;
			case 4:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack" || entry.animation.name == "attack3")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack4")
				{
					attack3katana();
				}
				else if (entry.animation.name == "attack5")
				{
					attack4none();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1katana();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2katana();
				}
				break;
			case 5:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack2")
				{
					attack4none();
				}
				else if (entry.animation.name == "attack5")
				{
					attack5Cloud();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Cloud();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Cloud();
				}
				break;
			case 6:
				AudioController.Instance.SoundPlayerPlayerCross();
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack1234Cross();
				}
				if (entry.animation.name == "attack5")
				{
					attack5Cross();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Cross();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Cross();
					countskillCross++;
				}
				break;
			case 7:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				if (entry.animation.name == "attack5")
				{
					attack4none();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Pike();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Pike();
				}
				break;
			case 8:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack3" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				if (entry.animation.name == "attack5")
				{
					if (isright)
					{
						GetComponent<Rigidbody2D>().AddForce(Vector2.right * 400f);
					}
					else
					{
						GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 400f);
					}
					attack4none();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Axe();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Axe();
				}
				break;
			case 9:
				if (entry.animation.name == "attack1" || entry.animation.name == "attack2" || entry.animation.name == "attack4")
				{
					attack123none();
				}
				else if (entry.animation.name == "attack3")
				{
					attack3Zed();
				}
				else if (entry.animation.name == "attack5")
				{
					attack5Zed();
				}
				else if (entry.animation.name == "skill1")
				{
					skill1Zed();
				}
				else if (entry.animation.name == "skill2")
				{
					skill2Zed();
				}
				break;
			}
		}
		else if (e.Data.name == "attack 1")
		{
			if (isright)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate(Effskill1Cloud, base.transform.position + new Vector3(1.2f, 0.65f, 0f), Quaternion.identity);
				gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 300f);
				gameObject.transform.localScale = new Vector3(-1f, 1f, 1f);
			}
			else
			{
				GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill1Cloud, base.transform.position + new Vector3(-1.2f, 0.65f, 0f), Quaternion.identity);
				gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 300f);
				gameObject2.transform.localScale = new Vector3(1f, 1f, 1f);
			}
		}
		else if (e.Data.name == "attack1")
		{
			for (int i = 0; i < GameManager.AllEnemy.Count; i++)
			{
				if (!GameManager.AllEnemy[i])
				{
					continue;
				}
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 2f)
				{
					Vector3 position = GameManager.AllEnemy[i].transform.position;
					float x = position.x;
					Vector3 position2 = base.transform.position;
					if (x < position2.x && !isright)
					{
						GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
						continue;
					}
				}
				if (distance < 2f)
				{
					Vector3 position3 = GameManager.AllEnemy[i].transform.position;
					float x2 = position3.x;
					Vector3 position4 = base.transform.position;
					if (x2 >= position4.x && isright)
					{
						GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
					}
				}
			}
		}
		else if (e.Data.name == "chuyen")
		{
			a++;
			chuyen = true;
			checkSound = false;
		}
	}

	private void FindEnemy()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if ((bool)GameManager.AllEnemy[i])
			{
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 10f)
				{
					_target = GameManager.AllEnemy[i];
				}
			}
		}
	}

	private void FindBoom()
	{
		for (int i = 0; i < GameManager.AllBoom.Count; i++)
		{
			if ((bool)GameManager.AllBoom[i])
			{
				distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[i].transform.position);
				if (distance1 < 2f)
				{
					_target1 = GameManager.AllBoom[i];
				}
			}
		}
	}

	private void OnTriggerEnter2D(Collider2D other)
	{
		if (other.gameObject.tag == "Coin")
		{
			AudioController.Instance.SoundPlayerEatItem();
			other.gameObject.GetComponent<GoldController>().isMagnet = true;
			other.gameObject.GetComponent<GoldController>()._value = increaseCoin;
		}
		else if (other.gameObject.tag == "Attack")
		{
			if (!istangdame)
			{
				GameObject obj = UnityEngine.Object.Instantiate(tangAttack, base.transform.position + new Vector3(0f, 1.8f, 0f), tangAttack.transform.rotation);
				StartCoroutine(tangdamage());
				UnityEngine.Object.Destroy(other.gameObject);
				UnityEngine.Object.Destroy(obj, 1f);
			}
			else
			{
				UnityEngine.Object.Destroy(other.gameObject);
			}
		}
		else if (other.gameObject.tag == "Defense")
		{
			if (!istangthu)
			{
				GameObject obj2 = UnityEngine.Object.Instantiate(tangDefense, base.transform.position + new Vector3(0f, 1.8f, 0f), tangAttack.transform.rotation);
				StartCoroutine(tangthu());
				UnityEngine.Object.Destroy(other.gameObject);
				UnityEngine.Object.Destroy(obj2, 1f);
			}
			else
			{
				UnityEngine.Object.Destroy(other.gameObject);
			}
		}
	}

	public void countDownBlood()
	{
		GameObject obj = UnityEngine.Object.Instantiate(EffOfLevelUp, base.transform.position + new Vector3(0f, 0.3f, 0f), EffOfLevelUp.transform.rotation);
		UnityEngine.Object.Destroy(obj, 1f);
		HealthPlayerNotTinker = (float)(500 * GameManager.levelPlayer) + healthOfWeapon;
		HealthTinkerIncrease = HealthPlayerNotTinker * 15f / 100f;
		HealthMaxPlayer = HealthPlayerNotTinker + HealthTinkerIncrease;
		healthLocal = HealthMaxPlayer;
		bloodPlayer.ClipRect = new Rect(0f, 0f, 1f, 1f);
	}

	public void Hit_Enemy(int damage)
	{
		if (!skill1 && !skill2 && !isSlide && !PlayerisDeath)
		{
			damage = damage * hesotangthu / 10;
			AudioController.Instance.SoundPlayerGetHit();
			HealthMaxPlayer -= damage;
			bloodPlayer.ClipRect = new Rect(bloodPlayer.ClipRect.x - (float)damage / healthLocal, 0f, 1f, 1f);
		}
		if (HealthMaxPlayer <= 0f && !PlayerisDeath)
		{
			PlayerisDeath = true;
			CancelInvoke("TinkerBuff");
			GameManager.numberRate--;
			SetAnim(AnimationName[10], loop: false);
			target.Lose();
			AudioController.Instance.SoundPlayerDeath();
		}
		if (!PlayerisDeath && !ishurt && !isSlide && !attack && !skill1 && !skill2 && !isBanra)
		{
			ishurt = true;
			SetAnim(AnimationName[1], loop: false);
		}
	}

	private void attack123none()
	{
		if (!checkSound)
		{
			ChangeSoundVuKhi();
			checkSound = true;
		}
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 1);
					continue;
				}
			}
			if (distance < distanceFollowStick)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 1);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void attack4none()
	{
		if (!checkSound)
		{
			ChangeSoundVuKhi();
			checkSound = true;
		}
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 0.4f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 0.4f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 0.4f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void attack3katana()
	{
		AudioController.Instance.SoundPlayerPlayerKatana();
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 1.9f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 1.9f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 1.9f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void attack4gay()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 0.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 0.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 0.5f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void attack34Dao()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 0.7f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 0.7f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: false, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 0.7f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void attack5Dao()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 1.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 1.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 1.5f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void skill1none()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if ((bool)GameManager.AllEnemy[i])
			{
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 2.4f)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 2, a: true, 2);
				}
			}
		}
	}

	private void skill2none()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 2.8f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 3 / 2, a: false, 2);
					continue;
				}
			}
			if (distance < 2.8f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 3 / 2, a: false, 2);
				}
			}
		}
	}

	private void skill1gay()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 4, a: true, 2);
					continue;
				}
			}
			if (distance < 5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 4, a: true, 2);
				}
			}
		}
	}

	private void skill2gay()
	{
		AudioController.Instance.SoundPlayerSkillGay2();
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if ((bool)GameManager.AllEnemy[i])
			{
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 4.2f)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 3, a: true, 2);
				}
			}
		}
	}

	private void skill1Claw()
	{
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Effskill2Claw, base.transform.position + new Vector3(0.8f, 1f, 0f), Quaternion.Euler(0f, 0f, -30f));
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 300f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill2Claw, base.transform.position + new Vector3(-0.8f, 1f, 0f), Quaternion.Euler(0f, 0f, 30f));
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 300f);
			gameObject2.transform.localScale = new Vector3(-1f, 1f, 1f);
		}
	}

	private void skill2Claw()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 7.2f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 5, a: true, 2);
					continue;
				}
			}
			if (distance < 7.2f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 5, a: true, 2);
				}
			}
		}
	}

	private void skill1katana()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 6.6f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 4, a: true, 2);
					continue;
				}
			}
			if (distance < 6.6f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 4, a: true, 2);
				}
			}
		}
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 3)
		{
			HandTutorial[4].SetActive(value: true);
			GameManager.number_tutorial++;
			GameObject.Find("Skill2").GetComponent<Collider>().enabled = true;
			GameObject.Find("Skill1").GetComponent<Collider>().enabled = false;
		}
	}

	private void skill2katana()
	{
		StartCoroutine(aaKatana());
		if (GameManager.Tutorial == 0 && GameManager.number_tutorial == 4)
		{
			GameManager.number_tutorial++;
			HandTutorial[5].SetActive(value: true);
			GameObject.Find("Skill2").GetComponent<Collider>().enabled = false;
			GameObject.Find("Slide").GetComponent<Collider>().enabled = true;
		}
	}

	private void skill1Dao()
	{
		AudioController.Instance.SoundPlayerSkillDao1();
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 3.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x)
				{
					GameManager.AllEnemy[i].GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 30f);
				}
				else
				{
					GameManager.AllEnemy[i].GetComponent<Rigidbody2D>().AddForce(Vector2.right * 30f);
				}
				GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer / 2, a: true, 2);
			}
		}
	}

	private void skill2Dao()
	{
		AudioController.Instance.SoundPlayerSkillDao2();
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if ((bool)GameManager.AllEnemy[i])
			{
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 6.6f)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 5, a: true, 2);
				}
			}
		}
	}

	private void attack5Cloud()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < distanceFollowStick + 1.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
					continue;
				}
			}
			if (distance < distanceFollowStick + 1.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
				}
			}
		}
		for (int j = 0; j < GameManager.AllBoom.Count; j++)
		{
			if (!GameManager.AllBoom[j])
			{
				continue;
			}
			distance1 = Vector3.Distance(base.transform.position, GameManager.AllBoom[j].transform.position);
			if (_target1 != null && distance1 < distanceFollowStick + 1.5f)
			{
				Vector3 position5 = GameManager.AllBoom[j].transform.position;
				float x3 = position5.x;
				Vector3 position6 = base.transform.position;
				if (x3 >= position6.x && isright)
				{
					_target1.transform.DOMove(new Vector3(18.8f, 0.8f, 0f), 1f);
				}
			}
		}
	}

	private void skill1Cloud()
	{
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Effskill1Cloud, base.transform.position + new Vector3(0.2f, 0.5f, 0f), Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 400f);
			gameObject.transform.localScale = new Vector3(-1.2f, 1.2f, 1f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill1Cloud, base.transform.position + new Vector3(-0.2f, 0.5f, 0f), Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 400f);
			gameObject2.transform.localScale = new Vector3(1.2f, 1.2f, 1f);
		}
	}

	private void skill2Cloud()
	{
		StartCoroutine(aaCloud());
	}

	private void attack1234Cross()
	{
		if (!checkSound)
		{
			ChangeSoundVuKhi();
			checkSound = true;
		}
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Bullet1Cross, attackOfCross.position, Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 400f);
			gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
			UnityEngine.Object.Destroy(gameObject, 1f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Bullet1Cross, attackOfCross.position, Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 400f);
			gameObject2.transform.localScale = new Vector3(-1f, 1f, 1f);
			UnityEngine.Object.Destroy(gameObject2, 1f);
		}
	}

	private void attack5Cross()
	{
		if (!checkSound)
		{
			ChangeSoundVuKhi();
			checkSound = true;
		}
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Bullet2Cross, attackOfCross.position, Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 400f);
			gameObject.transform.localScale = new Vector3(-1f, 1f, 1f);
			UnityEngine.Object.Destroy(gameObject, 0.6f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Bullet2Cross, attackOfCross.position, Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 400f);
			gameObject2.transform.localScale = new Vector3(1f, 1f, 1f);
			UnityEngine.Object.Destroy(gameObject2, 0.6f);
		}
	}

	private void skill1Cross()
	{
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Effskill1Cross, attackOfCross.position, Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 400f);
			gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill1Cross, attackOfCross.position, Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 400f);
			gameObject2.transform.localScale = new Vector3(-1f, 1f, 1f);
		}
	}

	private void skill2Cross()
	{
		if (isright)
		{
			GetComponent<Rigidbody2D>().velocity = -Vector2.right * 3f;
			GameObject gameObject = UnityEngine.Object.Instantiate(Effskill2Cross, attackOfCross.position, Quaternion.identity);
			if (countskillCross % 3 == 0)
			{
				gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0.7f, -1f) * 400f);
			}
			else if (countskillCross % 3 == 1)
			{
				gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(1.8f, -1.6f) * 400f);
			}
			else
			{
				gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(3f, -2f) * 400f);
			}
		}
		else
		{
			GetComponent<Rigidbody2D>().velocity = Vector2.right * 3f;
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill22Cross, attackOfCross.position, Quaternion.identity);
			if (countskillCross % 3 == 0)
			{
				gameObject2.GetComponent<Rigidbody2D>().AddForce(new Vector2(-0.7f, -1f) * 400f);
			}
			else if (countskillCross % 3 == 1)
			{
				gameObject2.GetComponent<Rigidbody2D>().AddForce(new Vector2(-1.8f, -1.6f) * 400f);
			}
			else
			{
				gameObject2.GetComponent<Rigidbody2D>().AddForce(new Vector2(-3f, -2f) * 400f);
			}
		}
	}

	private void skill1Pike()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 3.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 2);
					continue;
				}
			}
			if (distance < 3.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 2);
				}
			}
		}
	}

	private void skill2Pike()
	{
		StartCoroutine(aaPike());
	}

	private void skill1Axe()
	{
		if (atkSkAxe % 2 == 0)
		{
			if (isright)
			{
				GetComponent<Rigidbody2D>().AddForce(Vector2.right * 300f);
			}
			else
			{
				GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 300f);
			}
		}
		atkSkAxe++;
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 2.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer / 2, a: true, 2);
					continue;
				}
			}
			if (distance < 2.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer / 2, a: true, 2);
				}
			}
		}
	}

	private void skill2Axe()
	{
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if (!GameManager.AllEnemy[i])
			{
				continue;
			}
			distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
			if (distance < 7.5f)
			{
				Vector3 position = GameManager.AllEnemy[i].transform.position;
				float x = position.x;
				Vector3 position2 = base.transform.position;
				if (x < position2.x && !isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 5, a: true, 2);
					continue;
				}
			}
			if (distance < 7.5f)
			{
				Vector3 position3 = GameManager.AllEnemy[i].transform.position;
				float x2 = position3.x;
				Vector3 position4 = base.transform.position;
				if (x2 >= position4.x && isright)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer * 5, a: true, 2);
				}
			}
		}
	}

	private void attack3Zed()
	{
		AudioController.Instance.SoundPlayerPlayerClaw();
		for (int i = 0; i < GameManager.AllEnemy.Count; i++)
		{
			if ((bool)GameManager.AllEnemy[i])
			{
				distance = Vector3.Distance(base.transform.position, GameManager.AllEnemy[i].transform.position);
				if (distance < 2.4f)
				{
					GameManager.AllEnemy[i].gameObject.GetComponent<EnemyController>().Hit_Player(damagePlayer, a: true, 0);
				}
			}
		}
	}

	private void attack5Zed()
	{
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Effatk5Zed, AttackZed.position, Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 500f);
			gameObject.GetComponent<SkeletonAnimation>().skeleton.FlipX = false;
			UnityEngine.Object.Destroy(gameObject, 0.35f);
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effatk5Zed, AttackZed.position, Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 500f);
			gameObject2.GetComponent<SkeletonAnimation>().skeleton.FlipX = true;
			UnityEngine.Object.Destroy(gameObject2, 0.35f);
		}
	}

	private void skill1Zed()
	{
		if (isright)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate(Effskill1Zed, AttackZed.position, Quaternion.identity);
			gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 500f);
			gameObject.GetComponent<SkeletonAnimation>().skeleton.FlipX = false;
		}
		else
		{
			GameObject gameObject2 = UnityEngine.Object.Instantiate(Effskill1Zed, AttackZed.position, Quaternion.identity);
			gameObject2.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * 500f);
			gameObject2.GetComponent<SkeletonAnimation>().skeleton.FlipX = true;
		}
	}

	private void skill2Zed()
	{
		PlayerPhanThan.SetActive(value: true);
		if (isright)
		{
			Transform transform = PlayerPhanThan.transform;
			Vector3 position = base.transform.position;
			float x = Mathf.Clamp(position.x + 4f, -5f, 18.5f);
			Vector3 position2 = base.transform.position;
			transform.position = new Vector3(x, position2.y, 0f);
		}
		else
		{
			Transform transform2 = PlayerPhanThan.transform;
			Vector3 position3 = base.transform.position;
			float x2 = Mathf.Clamp(position3.x - 4f, -5f, 18.5f);
			Vector3 position4 = base.transform.position;
			transform2.position = new Vector3(x2, position4.y, 0f);
		}
		PlayerPhanThan.GetComponent<PlayerZedController>().damagePlayer = damagePlayer;
		StartCoroutine(aaSkill2Zed());
	}

	private IEnumerator countDownSkill1()
	{
		texhMeshNumberCountdown[0].gameObject.SetActive(value: true);
		countdown1();
		Boxskill1.gameObject.GetComponent<Collider>().enabled = false;
		Boxskill1.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 0.3f);
		yield return new WaitForSeconds(20f);
		texhMeshNumberCountdown[0].gameObject.SetActive(value: false);
		Boxskill1.gameObject.GetComponent<Collider>().enabled = true;
		Boxskill1.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 1f);
	}

	private IEnumerator countDownSkill2()
	{
		texhMeshNumberCountdown[1].gameObject.SetActive(value: true);
		countdown2();
		Boxskill2.gameObject.GetComponent<Collider>().enabled = false;
		Boxskill2.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 0.3f);
		yield return new WaitForSeconds(40f);
		texhMeshNumberCountdown[1].gameObject.SetActive(value: false);
		Boxskill2.gameObject.GetComponent<Collider>().enabled = true;
		Boxskill2.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 1f);
	}

	private IEnumerator countDownSlide()
	{
		texhMeshNumberCountdown[2].gameObject.SetActive(value: true);
		countdown3();
		BoxSlide.gameObject.GetComponent<Collider>().enabled = false;
		BoxSlide.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 0.3f);
		yield return new WaitForSeconds(0.5f);
		isGhost = false;
		yield return new WaitForSeconds(4.5f);
		texhMeshNumberCountdown[2].gameObject.SetActive(value: false);
		BoxSlide.gameObject.GetComponent<Collider>().enabled = true;
		BoxSlide.gameObject.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 1f);
	}

	private void countdown1()
	{
		countskill1countdown--;
		if (countskill1countdown >= 0)
		{
			Invoke("countdown1", 1f);
			texhMeshNumberCountdown[0].text = countskill1countdown.ToString();
			texhMeshNumberCountdown[0].Commit();
		}
		else
		{
			countskill1countdown = 20;
			CancelInvoke("countdown1");
		}
	}

	private void countdown2()
	{
		countskill2countdown--;
		if (countskill2countdown >= 0)
		{
			Invoke("countdown2", 1f);
			texhMeshNumberCountdown[1].text = countskill2countdown.ToString();
			texhMeshNumberCountdown[1].Commit();
		}
		else
		{
			countskill2countdown = 40;
			CancelInvoke("countdown2");
		}
	}

	private void countdown3()
	{
		countslidecountdown--;
		if (countslidecountdown >= 0)
		{
			Invoke("countdown3", 1f);
			texhMeshNumberCountdown[2].text = countslidecountdown.ToString();
			texhMeshNumberCountdown[2].Commit();
		}
		else
		{
			countslidecountdown = 5;
			CancelInvoke("countdown3");
		}
	}

	private IEnumerator aaCloud()
	{
		for (int i = 1; i < 6; i++)
		{
			AudioController.Instance.SoundPlayerSkillCloud2();
			GameObject eff3 = UnityEngine.Object.Instantiate(Effskill2Cloud, base.transform.position + new Vector3(i, 1f, 0f), Quaternion.identity);
			UnityEngine.Object.Destroy(eff3, 0.55f);
			GameObject eff2 = UnityEngine.Object.Instantiate(Effskill2Cloud, base.transform.position + new Vector3(-1 * i, 1f, 0f), Quaternion.identity);
			UnityEngine.Object.Destroy(eff2, 0.55f);
			yield return new WaitForSeconds(0.4f);
		}
	}

	private IEnumerator aaKatana()
	{
		GameObject eff4 = UnityEngine.Object.Instantiate(Effskill2Katana, base.transform.position + new Vector3(0f, 3f, 0f), Quaternion.identity);
		UnityEngine.Object.Destroy(eff4, 1f);
		for (int i = 1; i < 8; i++)
		{
			GameObject eff3 = UnityEngine.Object.Instantiate(Effskill2Katana, base.transform.position + new Vector3(i, 4f, 0f), Quaternion.identity);
			UnityEngine.Object.Destroy(eff3, 1f);
			GameObject eff2 = UnityEngine.Object.Instantiate(Effskill2Katana, base.transform.position + new Vector3(-1 * i, 4f, 0f), Quaternion.identity);
			UnityEngine.Object.Destroy(eff2, 1f);
			yield return new WaitForSeconds(0.2f);
		}
	}

	private IEnumerator aaPike()
	{
		if (isright)
		{
			for (int j = 1; j < 6; j++)
			{
				GameObject eff3 = UnityEngine.Object.Instantiate(Effskill2Pike, base.transform.position + new Vector3(j, 0f, 0f), Quaternion.identity);
				eff3.GetComponent<SkeletonAnimation>().skeleton.FlipX = false;
				UnityEngine.Object.Destroy(eff3, 0.4f);
				yield return new WaitForSeconds(0.2f);
			}
		}
		else
		{
			for (int i = 1; i < 6; i++)
			{
				GameObject eff2 = UnityEngine.Object.Instantiate(Effskill2Pike, base.transform.position + new Vector3(-1 * i, 0f, 0f), Quaternion.identity);
				eff2.GetComponent<SkeletonAnimation>().skeleton.FlipX = true;
				UnityEngine.Object.Destroy(eff2, 0.4f);
				yield return new WaitForSeconds(0.2f);
			}
		}
	}

	private IEnumerator aaSkill2Zed()
	{
		yield return new WaitForSeconds(20f);
		PlayerPhanThan.SetActive(value: false);
	}

	private void abc()
	{
		GameManager.number_tutorial++;
		CancelInvoke("abc");
	}

	public void OnclickHelpHealth()
	{
		if (HealthMaxPlayer < healthLocal && GameManager.numberHealth > 0)
		{
			GameManager.numberHealth--;
			GameObject obj = UnityEngine.Object.Instantiate(EffOfBuffHealth, base.transform.position + new Vector3(0f, 0.4f, 0f), EffOfBuffHealth.transform.rotation);
			UnityEngine.Object.Destroy(obj, 1.5f);
			HealthMaxPlayer += 4000f;
			if (HealthMaxPlayer > healthLocal)
			{
				HealthMaxPlayer = healthLocal;
				bloodPlayer.ClipRect = new Rect(0f, 0f, 1f, 1f);
			}
			else
			{
				bloodPlayer.ClipRect = new Rect(bloodPlayer.ClipRect.x + 4000f / healthLocal, 0f, 1f, 1f);
			}
			StartCoroutine(HoiMau());
		}
	}

	public void OnclickHelpHealth1()
	{
		if (HealthMaxPlayer < healthLocal && GameManager.numberBigHealth > 0)
		{
			GameManager.numberBigHealth--;
			GameObject obj = UnityEngine.Object.Instantiate(EffOfBuffHealth, base.transform.position + new Vector3(0f, 0.4f, 0f), EffOfBuffHealth.transform.rotation);
			UnityEngine.Object.Destroy(obj, 1.5f);
			HealthMaxPlayer += 20000f;
			if (HealthMaxPlayer > healthLocal)
			{
				HealthMaxPlayer = healthLocal;
				bloodPlayer.ClipRect = new Rect(0f, 0f, 1f, 1f);
			}
			else
			{
				bloodPlayer.ClipRect = new Rect(bloodPlayer.ClipRect.x + 20000f / healthLocal, 0f, 1f, 1f);
			}
			StartCoroutine(HoiMau());
		}
	}

	private IEnumerator HoiMau()
	{
		BoxHealth.GetComponent<Collider>().enabled = false;
		BoxHealth.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 0.3f);
		BoxBigHealth.GetComponent<Collider>().enabled = false;
		BoxBigHealth.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 0.3f);
		yield return new WaitForSeconds(0.2f);
		BoxBigHealth.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 1f);
		BoxBigHealth.GetComponent<Collider>().enabled = true;
		BoxHealth.GetComponent<tk2dSprite>().color = new Color(1f, 1f, 1f, 1f);
		BoxHealth.GetComponent<Collider>().enabled = true;
	}

	private void ChangeSoundVuKhi()
	{
		switch (GameManager.indexVukhi)
		{
		case 6:
			break;
		case 0:
			AudioController.Instance.SoundPlayerDam();
			break;
		case 1:
			AudioController.Instance.SoundPlayerPlayerGay();
			break;
		case 2:
			AudioController.Instance.SoundPlayerPlayerClaw();
			break;
		case 3:
			AudioController.Instance.SoundPlayerPlayerKatana();
			break;
		case 4:
			AudioController.Instance.SoundPlayerPlayerKatana();
			break;
		case 5:
			AudioController.Instance.SoundPlayerPlayerKatana();
			break;
		case 7:
			AudioController.Instance.SoundPlayerPlayerKatana();
			break;
		case 8:
			AudioController.Instance.SoundPlayerAxe();
			break;
		case 9:
			AudioController.Instance.SoundPlayerPlayerClaw();
			break;
		}
	}

	private void TinkerBuff()
	{
		if (HealthMaxPlayer < healthLocal)
		{
			HealthMaxPlayer += HealthTinkerBellperSecond;
			if (HealthMaxPlayer > healthLocal)
			{
				HealthMaxPlayer = healthLocal;
				bloodPlayer.ClipRect = new Rect(0f, 0f, 1f, 1f);
			}
			else
			{
				bloodPlayer.ClipRect = new Rect(bloodPlayer.ClipRect.x + HealthTinkerBellperSecond / healthLocal, 0f, 1f, 1f);
			}
		}
		Invoke("TinkerBuff", 1f);
	}

	private IEnumerator tangdamage()
	{
		istangdame = true;
		GameManager.hesotangdame = 2;
		bieutuongAttack.SetActive(value: true);
		yield return new WaitForSeconds(10f);
		bieutuongAttack.SetActive(value: false);
		GameManager.hesotangdame = 1;
		istangdame = false;
	}

	private IEnumerator tangthu()
	{
		istangthu = true;
		hesotangthu = 6;
		bieutuongThu.SetActive(value: true);
		yield return new WaitForSeconds(10f);
		bieutuongThu.SetActive(value: false);
		hesotangthu = 10;
		istangthu = false;
	}
}
